package com.ny.controller;

import com.ny.entity.Classrooms;
import com.ny.service.ClassroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ClassroomController {
    @Autowired
    private ClassroomService classroomService;
    @RequestMapping("/classroomsList")
    public String classroomsList(Model model){
        List<Classrooms> classroomsList = classroomService.findAllClassrooms();
        model.addAttribute("classroomsList", classroomsList);
        return "classroom";
    }
    @RequestMapping("/classroomsListl")
    public String classroomsListl(Model model){
        List<Classrooms> classroomsList = classroomService.findAllClassrooms();
        model.addAttribute("classroomsList", classroomsList);
        return "login";
    }
    @RequestMapping("/findClassrooms")
    public String findClassrooms(String classroomName,
                                 String building,
                                 String capacity,
                                 String status,
                                 Model model){
        List<Classrooms> classroomsList = classroomService.findClassrooms(classroomName, building, capacity, status);
        model.addAttribute("classroomsList", classroomsList);
        return "classroomManagement";
    }
}
